﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
    CodeFile="ChangePassword.aspx.cs" Inherits="user_ChangePassword" %>

<%@ Register Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" TagPrefix="asp" %>
<asp:Content ID="Content3" ContentPlaceHolderID="cphPageTitle" runat="Server">
    <h1>
        <asp:Label runat="server" Text="<%$Resources:Menu,ChangePassword%>" ID="lblPageName"></asp:Label></h1>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:Label runat="server" Text="<%$Resources:General,LangOption%>" Visible="false"
        ID="lblLangOption" />
    <asp:HyperLink runat="server" Visible="false" ID="lnkNewCarUsage" NavigateUrl="#"
        Text="New"></asp:HyperLink>
    <div class="bc2">
        <asp:Label runat="server" ID="lblSiteLocation" Text="You are here : " CssClass="bclist" />
        <asp:SiteMapPath SiteMapProvider="SiteUserSiteMapProvider" ID="smpProvider" runat="server"
            PathSeparator=" : ">
            <PathSeparatorStyle CssClass="bcarrow" />
            <CurrentNodeStyle CssClass="bclist" />
            <NodeStyle CssClass="bclink" />
            <RootNodeStyle CssClass="bclink" />
        </asp:SiteMapPath>
        <div class="clear">
        </div>
    </div>
    <div id="divChangePassword" class="toggle" runat="server">
        <div class="title opened" id="opened1">
            <img src="../images/icons/dark/key.png" alt="" class="titleIcon" />
            <h6>
                <asp:Label ID="lblChangePassword" runat="server" Text="<%$Resources:Menu,ChangePassword%>" />
            </h6>
        </div>
        <div class="form">
            <fieldset class="step">
                <asp:UpdatePanel ID="upnlDetails" runat="server">
                    <ContentTemplate>
                        <asp:Panel ID="pnlDetails" runat="server">
                            <div class="formRow">
                                <asp:Label runat="server" ID="lblCurrentPasswordCaption" Text="<%$Resources:Menu,CurrentPassword%>" />
                                <div class="formRight">
                                    <asp:TextBox ID="txtOldPassword" runat="server" MaxLength="20" Width="150px" TextMode="Password"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="rfvOldPassword" runat="server" ControlToValidate="txtOldPassword"
                                        Display="Dynamic" ErrorMessage="<%$Resources:Menu,RequireCurrentPasswordMessage%>"
                                        Text="<%$Resources:Menu,RequireCurrentPasswordMessage%>" ValidationGroup="customer"></asp:RequiredFieldValidator>
                                </div>
                                <div class="clear">
                                </div>
                            </div>
                            <div class="formRow">
                                <asp:Label runat="server" ID="lblNewPasswordCaption" Text="<%$Resources:Menu,NewPassword%>" />
                                <div class="formRight">
                                    <asp:TextBox ID="txtNewPassword" runat="server" MaxLength="20" Width="150px" TextMode="Password"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="rfvNewPassword" runat="server" ControlToValidate="txtNewPassword"
                                        Display="Dynamic" ErrorMessage="<%$Resources:Menu,RequireNewPasswordMessage%>"
                                        Text="<%$Resources:Menu,RequireNewPasswordMessage%>" ValidationGroup="customer"></asp:RequiredFieldValidator>
                                    <asp:RegularExpressionValidator ID="revNewPassword" runat="server" ControlToValidate="txtNewPassword"
                                        ValidationExpression="^\w*(?=\w*\d{2})(?=\w*[a-z]{2})(?=\w*[A-Z]{2})\w{8,20}$"
                                        Display="Dynamic" ErrorMessage="<%$Resources:Menu,PasswordFormatMessage%>" ValidationGroup="customer" />
                                </div>
                                <div class="clear">
                                </div>
                            </div>
                            <div class="formRow">
                                <asp:Label runat="server" ID="lblConfirmPasswordCaption" Text="<%$Resources:Menu,ConfirmPassword%>" />
                                <div class="formRight">
                                    <asp:TextBox ID="txtConfirmPassword" runat="server" MaxLength="20" Width="150px"
                                        TextMode="Password"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="rfvConfirmPassword" runat="server" ControlToValidate="txtConfirmPassword"
                                        Display="Dynamic" ErrorMessage="<%$Resources:Menu,RequireConfirmPasswordMessage%>"
                                        Text="<%$Resources:Menu,RequireConfirmPasswordMessage%>" ValidationGroup="customer"></asp:RequiredFieldValidator>
                                    <asp:CompareValidator ID="csvConfirmPassword" runat="server" ControlToCompare="txtNewPassword"
                                        ControlToValidate="txtConfirmPassword" Display="Dynamic" ErrorMessage="<%$Resources:Menu,PasswordMustSameMessage%>"
                                        Text="<%$Resources:Menu,PasswordMustSameMessage%>" ValidationGroup="customer"></asp:CompareValidator>
                                </div>
                                <div class="clear">
                                </div>
                            </div>
                            <div class="formRow">
                                <asp:Label runat="server" ID="Label7" Text="" />
                                <div class="formRight">
                                    <asp:Button ID="btnSubmit" runat="server" CssClass="blueB ml10" OnClick="btnSubmit_Click" Text="<%$Resources:Menu,ChangePassword%>"
                                        ValidationGroup="customer" />&nbsp;
                            <asp:Label ID="lblMessage" ForeColor="Red" runat="server"></asp:Label>
                                </div>
                                <div class="clear">
                                </div>
                            </div>
                        </asp:Panel>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </fieldset>
        </div>
    </div>
    <script type="text/javascript">
        function CheckPasswordLength(source, arguments) {
            //var corglen = arguments.Value;
            var cval = arguments.Value;
            var bValid = true;
            var chList = new Array(20);
            var ctrlsource = document.getElementById(source.id);

            //alert("ORG LEN : " + corglen.length + " AFTER : " + cval.length);
            if (cval.indexOf(' ') != -1 || cval.indexOf('\'') != -1
                        || cval.indexOf('\"') != -1 || cval.indexOf('~') != -1) {
                if (ctrlsource.textContent) {
                    ctrlsource.textContent = "<%=GetGlobalResourceObject("Menu", "CPmsgPasswordInvalidChar")%>";//"Password include invalid character or space!";
                }
                else {
                    ctrlsource.innerText = "<%=GetGlobalResourceObject("Menu", "CPmsgPasswordInvalidChar")%>";//"Password include invalid character or space!";
                }

                ctrlsource.errormessage = "<%=GetGlobalResourceObject("Menu", "CPmsgPasswordInvalidChar")%>";//"Password include invalid character or space!";
                bValid = false;
            }
            else if (cval.length < 8) {
                if (ctrlsource.textContent) {
                    ctrlsource.textContent = "<%=GetGlobalResourceObject("Menu", "CPmsgPasswordLengthMinimum8")%>";//"Password length should be at least 8";
                }
                else {
                    ctrlsource.innerText = "<%=GetGlobalResourceObject("Menu", "CPmsgPasswordLengthMinimum8")%>;"//"Password length should be at least 8";
                }

                ctrlsource.errormessage = "<%=GetGlobalResourceObject("Menu", "CPmsgPasswordLengthMinimum8")%>";//"Password length should be at least 8";
                bValid = false;
            }
            else if (cval.length > 20) {
                bValid = false;
                if (ctrlsource.textContent) {
                    ctrlsource.textContent = "<%=GetGlobalResourceObject("Menu", "CPmsgPasswordLengthMaximum20")%>";//"Password length should not be over 20!";
                }
                else {
                    ctrlsource.innerText = "<%=GetGlobalResourceObject("Menu", "CPmsgPasswordLengthMaximum20")%>";//"Password length should not be over 20!";
                }
                ctrlsource.errormessage = "<%=GetGlobalResourceObject("Menu", "CPmsgPasswordLengthMaximum20")%>";//"Password length should not be over 20!";
            }
            else {
                bValid = true;
            }
            //alert(cval);
            //if (isNaN(cval)){
            //    bValid = false;
            //} 


            //alert(bValid);
            arguments.IsValid = bValid;
            return;
        }
    </script>

</asp:Content>
